import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
    {
    title: '租户id',
    align:"center",
    dataIndex: 'tenantId'
   },
   {
    title: '姓名',
    align:"center",
    dataIndex: 'patientName'
   },
   {
    title: '性别',
    align:"center",
    dataIndex: 'sex_dictText'
   },
   {
    title: '出生日期',
    align:"center",
    dataIndex: 'birthDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
   {
    title: '证件类型',
    align:"center",
    dataIndex: 'certificateType_dictText'
   },
   {
    title: '证件号',
    align:"center",
    dataIndex: 'certificateId'
   },
   {
    title: '手机号',
    align:"center",
    dataIndex: 'phone'
   },
   {
    title: '年龄',
    align:"center",
    dataIndex: 'age'
   },
   {
    title: '现住址',
    align:"center",
    dataIndex: 'nowAddressRegion',
    slots: { customRender: 'pcaSlot' },//TODO 未翻译
   },
   {
    title: '详细地址',
    align:"center",
    dataIndex: 'nowAddressDetail'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '租户id',
    field: 'tenantId',
    component: 'Input',
  },
  {
    label: '姓名',
    field: 'patientName',
    component: 'Input',
  },
  {
    label: '性别',
    field: 'sex',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"sex"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入性别!'},
          ];
     },
  },
  {
    label: '出生日期',
    field: 'birthDate',
    component: 'DatePicker',
  },
  {
    label: '证件类型',
    field: 'certificateType',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:""
     },
  },
  {
    label: '证件号',
    field: 'certificateId',
    component: 'Input',
  },
  {
    label: '手机号',
    field: 'phone',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: false},
                 { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!'},
          ];
     },
  },
  {
    label: '年龄',
    field: 'age',
    component: 'InputNumber',
  },
  {
    label: '现住址',
    field: 'nowAddressRegion',
    component: 'JAreaLinkage',
  },
  {
    label: '详细地址',
    field: 'nowAddressDetail',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

//子表列表数据
export const patExtendInfoColumns: BasicColumn[] = [
   {
    title: '租户id',
    align:"center",
    dataIndex: 'tenantId'
   },
   {
    title: '病人id',
    align:"center",
    dataIndex: 'patientId'
   },
   {
    title: '民族',
    align:"center",
    dataIndex: 'nation'
   },
   {
    title: '现住省',
    align:"center",
    dataIndex: 'nowAddressProvince'
   },
   {
    title: '现住市',
    align:"center",
    dataIndex: 'nowAddressCity'
   },
   {
    title: '现住区',
    align:"center",
    dataIndex: 'nowAddressCounty'
   },
   {
    title: '现住详细地址',
    align:"center",
    dataIndex: 'nowAddressDetail'
   },
];
//子表表单数据
export const patExtendInfoFormSchema: FormSchema[] = [
  // TODO 子表隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
  {
    label: '租户id',
    field: 'tenantId',
    component: 'Input',
    dynamicDisabled:true,
  },
  {
    label: '病人id',
    field: 'patientId',
    component: 'Input',
    dynamicDisabled:true,
  },
  {
    label: '民族',
    field: 'nation',
    component: 'Input',
  },
  {
    label: '现住省',
    field: 'nowAddressProvince',
    component: 'Input',
  },
  {
    label: '现住市',
    field: 'nowAddressCity',
    component: 'Input',
  },
  {
    label: '现住区',
    field: 'nowAddressCounty',
    component: 'Input',
  },
  {
    label: '现住详细地址',
    field: 'nowAddressDetail',
    component: 'Input',
  },
];
